package com.iweb.tmall.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iweb.tmall.entity.BaseEntity;
import com.iweb.tmall.global.ResponseData;
import com.iweb.tmall.param.BaseParam;
//业务层代码接口
public interface IService<P extends BaseParam,E extends BaseEntity> {
    ResponseData getList(P param);
    ResponseData deleteById(Integer id);
    ResponseData updateById(E entity);
    ResponseData save(E entity);//add
    ResponseData getById(Integer id);//view
    //获取lambda条件构造器对象
    default LambdaQueryWrapper<E> getLambdaQueryWrapper(E entity){
        return new LambdaQueryWrapper<E>()
                .setEntityClass((Class<E>) entity.getClass())
                .eq(E::getIsDelete,0);
    }
    default LambdaQueryWrapper<E> getLambdaQueryWrapper(){
        return new LambdaQueryWrapper<E>();
    }
    //获取普通条件构造器对象
    default QueryWrapper<E> getQueryWrapper(){
        return new QueryWrapper<E>().eq("is_delete",0);
    }
}
